<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>茶叶主页</title>
    <script src="../js/axios.min.js"></script>
</head>
<body>
<table border="1" cellspacing="0" width="100%" id="teaTbale">

</table>

<script>
    //网页标签加载完后会触发onload事件，调用匿名函数
    window.onload=function (){
        axios.get("/JMS2301_03_javaWeb_war/queryTeaAll").then(function (resp) {
            let teas = resp.data;
            console.log(teas)
            let tableData = " <tr>\n" +
                "        <th>id</th>\n" +
                "        <th>茶叶名称</th>\n" +
                "        <th>茶叶类别</th>\n" +
                "        <th>排序</th>\n" +
                "        <th>描述</th>\n" +
                "        <th>状态</th>\n" +
                "        <th>操作</th>\n" +
                "    </tr>";

            //遍历users
            for (let i = 0; i < teas.length; i++) {
                let tea=teas[i];
                tableData+="\n"+
                    " <tr>\n"+
                    "        <td>"+tea.id+"</td>\n" +
                    "        <td>"+tea.teaName+"</td>\n" +
                    "        <td>"+tea.teaTypeId+"</td>\n" +
                    "        <td>"+tea.ordered+"</td>\n" +
                    "        <td>"+tea.description+"</td>\n" +
                    "        <td>"+tea.status+"</td>\n" +
                    "        <td><a href='#'>修改</a><a href='#'>删除</a></td>\n" +
                    "    </tr>";
            }
            //设置表格数据
            document.getElementById("teaTbale").innerHTML=tableData;
        })
    }


</script>
</body>
</html>